package com.p2l.letterblocks;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.Paint.Align;

public class Pause {
	private GamePersistor persistor;
	private Bitmap background;
	private Button yes, no;
	private Paint p;
	private Rect dst;
	
	private boolean paused;
	
	public Pause(GamePersistor persistor, Bitmap button, Bitmap background) {
		this.background = background;
		this.persistor = persistor;
		
		yes = new Button(persistor, (GamePersistor.SCREEN_WIDTH / 2) - (GamePersistor.SCREEN_WIDTH / 100f * 5f) - (GamePersistor.SCREEN_WIDTH / 100f * 25f), (GamePersistor.SCREEN_HEIGHT / 3 * 2) - (GamePersistor.SCREEN_HEIGHT / 100f * 12.5f), 12.5f, 25f, false, persistor.getResources().getString(R.string.ingame_yes), new Bitmap[]{ button, button });
		yes.setEnabled(true);
		no = new Button(persistor, (GamePersistor.SCREEN_WIDTH / 2) + (GamePersistor.SCREEN_WIDTH / 100f * 5f), (GamePersistor.SCREEN_HEIGHT / 3 * 2) - (GamePersistor.SCREEN_HEIGHT / 100f * 12.5f), 12.5f, 25f, false, persistor.getResources().getString(R.string.ingame_no), new Bitmap[]{ button, button });
		no.setEnabled(true);
		
		p = new Paint();
		p.setTextSize(persistor.getResources().getDimension(R.dimen.text_ingame));
		p.setTypeface(Typeface.DEFAULT_BOLD);
		p.setTextAlign(Align.CENTER);
		
		dst = new Rect(0, 0, GamePersistor.SCREEN_WIDTH, GamePersistor.SCREEN_HEIGHT);
		
		paused = false;
	}
	
	public boolean isPaused() {
		return paused;
	}

	public void setPaused(boolean paused) {
		this.paused = paused;
	}
	
	public Button getYesButton() {
		return yes;
	}
	
	public Button getNoButton() {
		return no;
	}

	public void onDraw(Canvas c) {
		// draw background	
		c.drawBitmap(background, null, dst, null);
		
		// draw text
		c.drawText(persistor.getResources().getString(R.string.ingame_exit_game), GamePersistor.SCREEN_WIDTH / 2, GamePersistor.SCREEN_HEIGHT / 3, p);
		
		// draw buttons
		yes.onDraw(c, 0, 0f);
		no.onDraw(c, 0, 0f);
	}
}
